//
//  YDYPresentionController.m
//  DY_Weibo3
//
//  Created by 杨德勇 on 2016/8/18.
//  Copyright © 2016年 杨德勇. All rights reserved.
//

#import "YDYPresentionController.h"
@interface YDYPresentionController()
/** 背景按钮，负责点击让菜单消失 */
@property (nonatomic, strong) UIButton *backBtn;
@end

@implementation YDYPresentionController
-(instancetype)initWithPresentedViewController:(UIViewController *)presentedViewController presentingViewController:(UIViewController *)presentingViewController{
    
    return [super initWithPresentedViewController:presentedViewController presentingViewController:presentingViewController];
    
}

-(void)containerViewWillLayoutSubviews{
    [self.containerView insertSubview:self.backBtn atIndex:0];
    self.presentedView.frame = self.presentFrame;
    self.backBtn.frame = [UIApplication sharedApplication].keyWindow.bounds;
}
-(void)dismissView{
   
    [self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark -
#pragma mark -懒加载
-(UIButton *)backBtn{
    if (_backBtn == nil) {
        UIButton *btn = [[UIButton alloc]init];
        
        [btn addTarget:self action:@selector(dismissView) forControlEvents:UIControlEventTouchUpInside];
        _backBtn = btn;
        
    }
    return _backBtn;
}
@end
